package jsyf.oa.web.wechartSec;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.wechartSec.WechartDeviceBrandFacade;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/4/8.
 */
@Api(value = "品牌测试接口", description = "品牌测试接口")
@Controller
@RequestMapping("/wechartDeviceBrand")
public class WechartDeviceBrandController {

    @Resource
    private WechartDeviceBrandFacade wechartDeviceBrandFacade;

    @RequestMapping(value = "/save.json", method = RequestMethod.POST)
    public void save(HttpServletResponse response, @RequestBody String jsonData) {
        String resultId = this.wechartDeviceBrandFacade.save(jsonData);
        String result = "";
        if ("".equals(resultId)) {
            result = BaseUtils.errorrRespond("服务器错误");
        } else {
            JSONObject obj = new JSONObject();
            obj.put("id", resultId);
            result = BaseUtils.succsessObjRespond(obj);
        }
        ResponseUtils.putJsonResponse(response, result);
    }
    @RequestMapping(value = "/getBrandList.json", method = RequestMethod.POST)
    public void getCompanyList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = wechartDeviceBrandFacade.getBrandList();
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }



}